package com.weixin.paleituo.activity;

import android.content.Context;
import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.weixin.paleituo.R;
import com.weixin.paleituo.adapter.MyBrokeragePagerAdapter;
import com.weixin.paleituo.base.BasePersonActivity;
import com.weixin.paleituo.util.UIUtils;

import butterknife.BindView;

/**
 * 我的佣金界面
 *
 * @author fengzhen
 * @version v1.0, 2018/5/11
 */
public class MyBrokerageActivity extends BasePersonActivity {

    public static final String BROKERAGE_TYPE = "brokerage_type";

    @BindView(R.id.tab_activity_my_brokerage)
    TabLayout mTabActivityMyBrokerage;
    @BindView(R.id.viewpager_activity_my_brokerage)
    ViewPager mViewpagerActivityMyBrokerage;

    /**
     * 跳转我的佣金界面
     *
     * @param type 0:余额  1：发放中  2：已提用
     * @author fengzhen
     * @version v1.0, 2018/5/14
     */
    public static Intent call2MyBrokerageActivity(Context context, int type) {
        Intent intent = new Intent(context, MyBrokerageActivity.class);
        intent.putExtra(BROKERAGE_TYPE, type);
        return intent;
    }

    @Override
    protected View getContentView(Context context) {
        return UIUtils.inflate(this, R.layout.activity_my_brokerage);
    }

    @Override
    protected void initData() {
        super.initData();
        mTvTitle.setText("我的佣金");
        mTvSmalTitle.setText("");
        mTvSmalTitle.setVisibility(View.VISIBLE);
        mTvSmalTitle.setCompoundDrawablesWithIntrinsicBounds(
                ContextCompat.getDrawable(this, R.mipmap.icon_withdraw), null, null, null
        );
        int position = getIntent().getIntExtra(BROKERAGE_TYPE, 0);

        mViewpagerActivityMyBrokerage.setAdapter(new MyBrokeragePagerAdapter(
                getSupportFragmentManager(), new String[]{"余额", "发放中", "已提用"}));
        mTabActivityMyBrokerage.setupWithViewPager(mViewpagerActivityMyBrokerage);
        mViewpagerActivityMyBrokerage.setCurrentItem(position);
        mViewpagerActivityMyBrokerage.setOffscreenPageLimit(3);
    }

    @Override
    protected void save(View v) {
        super.save(v);
        startActivity(BrokerageWithdrawActivity.call2BrokerageWithdrawActivity(this));
    }
}
